package visuals;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;

/**
 * Created by IntelliJ IDEA.
 * User: Aleksey
 * Date: 03.01.2008
 * Time: 1:50:53
 */
public class SouthPanel extends JPanel {
    public SouthPanel() {
        super();
        setLayout(new FlowLayout(FlowLayout.LEFT));
        JButton bNext = new JButton("Next bar");
        JButton bPrev = new JButton("Previous bar");
        JButton bCopyToNext = new JButton("Copy to next");
        JButton bCopyToPrev = new JButton("Copy to previous");
        JButton bDelete = new JButton("Delete bar");
        JButton bInsert = new JButton("Insert bar");
        JButton bSave = new JButton("Save (Ctrl+S)");
        JButton bCreate = new JButton("Create bar");
        JButton bClear = new JButton("Clear bar");

        add(bPrev);
        add(bNext);
        add(bCreate);
        add(bInsert);
        add(bDelete);
        add(bCopyToPrev);
        add(bCopyToNext);
        add(bClear);
        add(bSave);

        bPrev.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                ActionController.selectPreviousBar(1);
            }
        });
        bNext.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                ActionController.selectNextBar(1);
            }
        });
        bCopyToPrev.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                ActionController.copyCurrentBarToPrevious();
            }
        });
        bCopyToNext.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                ActionController.copyCurrentBarToNext();
            }
        });
        bDelete.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                ActionController.deleteCurrentBar();
            }
        });
        bInsert.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                ActionController.insertNewBarBeforeCurrent();
            }
        });
        bSave.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                ActionController.saveTrack();
            }
        });
        bCreate.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                ActionController.addNewBarToTheEnd();
            }
        });
        bClear.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                ActionController.clearAll();
            }
        });
    }
}
